package com.mysteel.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;

import com.mysteel.common.valid.AddGroup;
import com.mysteel.common.valid.UpdateGroup;
import com.mysteel.common.valid.UpdateShowStatusGroup;
import com.mysteel.common.validation.ListValue;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 品牌
 *
 * @author xc
 * @email xcremote@163.com
 * @date 2020-12-10 16:50:04
 */

/**
 * 分组校验：@NotNull(message = "修改品牌ID不能为空", groups = {UpdateGroup.class})
 * 1、编写不同类型的校验分组UpdateGroup.class
 * 2、给注解校验标注什么情况下需要进行校验
 * 3、在controller使用@Validated(AddGroup.class)添加分组
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 品牌id
     */
    @TableId
    @NotNull(message = "修改品牌ID不能为空", groups = {UpdateGroup.class, UpdateShowStatusGroup.class})
    @Null(message = "新增品牌ID必须为空", groups = {AddGroup.class})
    private Long brandId;
    /**
     * 品牌名
     */
    @NotBlank(message = "品牌名不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private String name;
    /**
     * 品牌logo地址
     */
    @NotEmpty(groups = {AddGroup.class})
    @URL(message = "logo必须为一个有效的URL地址",groups = {AddGroup.class,UpdateGroup.class})
    private String logo;
    /**
     * 介绍
     */
    private String descript;
    /**
     * 显示状态[0-不显示；1-显示]
     */
    @ListValue(vals = {0,1},groups = {AddGroup.class, UpdateShowStatusGroup.class})
    private Integer showStatus;
    /**
     * 检索首字母
     */
    @Pattern(regexp = "^[a-zA-Z]$", message = "检索首字母必须是一个字母",groups = {AddGroup.class,UpdateGroup.class})
    private String firstLetter;
    /**
     * 排序
     */
    @Min(value = 0, message = "排序字段的值不能小于0",groups = {AddGroup.class,UpdateGroup.class})
    private Integer sort;

}
